package com.woniu.service.impl;

import com.woniu.dao.UserDAO;
import com.woniu.pojo.User;
import com.woniu.service.UserService;
import com.woniu.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDAO userDAO;

    @Override
    public List<User> findUserList(Integer currentPage, Integer pageSize, UserVO userVO) {
        return userDAO.queryUserByPage(currentPage,pageSize,userVO);
    }

    @Override
    public int saveUser(User user) {
        return userDAO.insertSelective(user);
    }

    @Override
    public void deleteUser(Integer[] primarykeys) {
           userDAO.deleteUser(primarykeys);
    }

    @Override
    public User findUser(User user) {
        User _user = userDAO.findUserByName(user.getUserName());
        if(_user != null && user.getPassword().equals(_user.getPassword())){
            return _user;
        }
        return null;
    }
}
